home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / intuisup.lha / Intuisup / source.lha / Requester / requester.c < prev    next >
C/C++ Source or Header  |  1992-07-28  |  20KB  |  612 lines

  1. /* $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1991 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: requester.c
  6.  *    Created ..: Thursday 19-Dec-91 18:55:19
  7.  *    Revision .: 5
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    28-Jul-92   Torsten Jürgeleit      different centering types for
  12.  *                                         requesters
  13.  *    19-Jul-92   Torsten Jürgeleit      remove/display_visible_gadget_lists()
  14.  *                                         moved to gadgets1.c and instead of
  15.  *                       remove/display_visible_gadget_lists()
  16.  *                                         now change_mouse_pointer(...,TRUE)
  17.  *    30-Apr-92   Torsten Jürgeleit      now requester support rasters
  18.  *    01-Apr-92   Torsten Jürgeleit      restore old mouse pointer position
  19.  *                                         after displaying requester
  20.  *    28-Dec-91   Torsten Jürgeleit      auto requester with body text string
  21.  *                                         (with '\n' as new line indicator)
  22.  *                                         instead of text array
  23.  *    19-Dec-91   Torsten Jürgeleit      Created this file!
  24.  *
  25.  ****************************************************************************
  26.  *
  27.  *    Requester support routines
  28.  *
  29.  * $Revision Header ********************************************************/
  30.  
  31.     /* Includes */
  32.  
  33. #include <exec/types.h>
  34. #include <exec/memory.h>
  35. #include <graphics/text.h>
  36. #include <intuition/intuition.h>
  37. #include <intuition/screens.h>
  38. #ifdef AZTEC_C
  39. #include <functions.h>   /* needed for Aztec C - prototypes and pragmas for all Amiga system functions */
  40. #endif
  41. #include <libraries/memwatch.h>   /* header file for memory debug link library (Fish 240) - AFTER functions.h */
  42. #include <string.h>
  43. #include <ctype.h>
  44. #include "/render/render.h"
  45. #include "/texts/texts.h"
  46. #include "/borders/borders.h"
  47. #include "/gadgets/gadgets.h"
  48. #include "/gadgets/imports.h"
  49. #include "/language/language.h"
  50. #include "/pointer/pointer.h"
  51. #include "requester.h"
  52.  
  53.     /* Defines for auto request */
  54.  
  55. #define AUTO_REQ_DETAIL_PEN    0
  56. #define AUTO_REQ_BLOCK_PEN    1
  57.  
  58. #define AUTO_REQ_IDCMP_FLAGS    (GADGET_IDCMP_FLAGS_BUTTON | pos_idcmp_flags | neg_idcmp_flags)
  59. #define AUTO_REQ_FLAGS        (WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE)
  60. #define AUTO_REQ_HORIZ_OFFSET    10
  61. #define AUTO_REQ_VERT_OFFSET    5
  62. #define AUTO_REQ_VERT_SPACING    2
  63.  
  64. #define AUTO_REQ_GADGET_HORIZ_BORDER_OFFSET    8
  65. #define AUTO_REQ_GADGET_VERT_BORDER_OFFSET    4
  66. #define AUTO_REQ_GADGET_HORIZ_SPACING        20
  67. #define AUTO_REQ_GADGET_VERT_SPACING        10
  68.  
  69.     /* Defines for requester */
  70.  
  71. #define REQ_DETAIL_PEN        0
  72. #define REQ_BLOCK_PEN        1
  73. #define REQ_IDCMP_FLAGS        GADGET_IDCMP_FLAGS_ALL
  74. #define REQ_FLAGS        (SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE)
  75.  
  76.     /* Externals */
  77.  
  78. IMPORT struct IntuitionBase  *IntuitionBase;
  79.  
  80.     /* Display auto request */
  81.  
  82.    BOOL
  83. auto_request(struct Window  *req_win, BYTE *title, BYTE *body_text,
  84.                BYTE *pos_text, BYTE *neg_text, LONG pos_idcmp_flags,
  85.      LONG neg_idcmp_flags, USHORT req_flags, BYTE **language_text_array)
  86. {
  87.    BOOL result = FALSE;
  88.  
  89.    if (body_text && (pos_text || neg_text)) {
  90.       struct RenderInfo  *ri;
  91.       struct Screen      *screen;
  92.       struct MinList     list;
  93.       ULONG flags;
  94.  
  95.       if (req_win) {
  96.  
  97.      /* Remove gadgets and menu from given window */
  98.      change_mouse_pointer(req_win, NULL, TRUE);
  99.       }
  100.  
  101.       /* Get render info */
  102.       screen = (req_win ? req_win->WScreen : NULL);
  103.       flags  = RENDER_INFO_FLAG_INNER_WINDOW | (req_flags &
  104.           AUTO_REQ_FLAG_BACK_FILL ? RENDER_INFO_FLAG_BACK_FILL : 0);
  105.       if (ri = get_render_info(screen, (USHORT)flags)) {
  106.      BYTE *text;
  107.      LONG text_len;
  108.  
  109.      /* Make copy of body text */
  110.      body_text = get_language_text(body_text, language_text_array);
  111.      text_len  = strlen(body_text) + 2;
  112.      if (text = AllocMem(text_len, (LONG)MEMF_PUBLIC)) {
  113.         struct TextAttr    *ta = &ri->ri_TextAttr;
  114.         struct GadgetData  gadget_data[3], *gd = &gadget_data[0];
  115.         struct GadgetList  *gl;
  116.         USHORT count, len1, len2, width1, width2, width, height,
  117.            gad_width, gad_height, num_gadgets, inner_width,
  118.            inner_height;
  119.         BYTE   *ptr = text + 1, *line = text;
  120.  
  121.         strcpy(ptr, body_text);
  122.         *(ptr + text_len - 2) = '\0';
  123.  
  124.         /* Mark mark/count lines in body text string */
  125.         width1 = 0;
  126.         count  = 1;
  127.         while ((ptr = strchr(ptr, '\\')) && toupper(*(ptr + 1)) == 'N') {
  128.  
  129.            /* Save line length and mark end of line */
  130.            *line = ptr - (line + 1);
  131.            *ptr  = '\0';
  132.  
  133.            /* Calc max width of body text */
  134.            if ((len1 = print_text(ri, NULL, line + 1, 0, 0,
  135.                    TEXT_DATA_TYPE_TEXT, TEXT_DATA_FLAG_NO_PRINT,
  136.                                 ta)) > width1) {
  137.           width1 = len1;
  138.            }
  139.  
  140.            /* Increment pointers and line counter */
  141.            line = ptr + 1;
  142.            ptr += 2;
  143.            count++;
  144.         }
  145.  
  146.         /* Prepare last line of body text */
  147.         *line = strlen(line + 1);
  148.         if ((len1 = print_text(ri, NULL, line + 1, 0, 0,
  149.                    TEXT_DATA_TYPE_TEXT, TEXT_DATA_FLAG_NO_PRINT,
  150.                                 ta)) > width1) {
  151.            width1 = len1;
  152.         }
  153.  
  154.         /* Calc max width of gadgets */
  155.         num_gadgets = 2;
  156.         if (!pos_text) {
  157.            len1        = 0;
  158.            num_gadgets = 1;
  159.         } else {
  160.            len1 = print_text(ri, NULL, get_language_text(pos_text,
  161.                 language_text_array), 0, 0, TEXT_DATA_TYPE_TEXT,
  162.                            TEXT_DATA_FLAG_NO_PRINT, ta);
  163.         }
  164.         if (!neg_text) {
  165.            len2        = 0;
  166.            num_gadgets = 1;
  167.         } else {
  168.            len2 = print_text(ri, NULL, get_language_text(neg_text,
  169.                 language_text_array), 0, 0, TEXT_DATA_TYPE_TEXT,
  170.                            TEXT_DATA_FLAG_NO_PRINT, ta);
  171.         }
  172.         gad_width  = (len1 > len2 ? len1 : len2) +
  173.                     2 * AUTO_REQ_GADGET_HORIZ_BORDER_OFFSET;
  174.         gad_height = ta->ta_YSize +
  175.                      2 * AUTO_REQ_GADGET_VERT_BORDER_OFFSET;
  176.         width2     = num_gadgets * gad_width + (num_gadgets == 2 ?
  177.                      AUTO_REQ_GADGET_HORIZ_SPACING : 0);
  178.         /* Calculate dimension of text area */
  179.         inner_width  = (width1 > width2 ? width1 : width2);
  180.         inner_height = count * ta->ta_YSize + (count - 1) *
  181.                               AUTO_REQ_VERT_SPACING;
  182.         /* Leave free space between raster and text */
  183.         if (req_flags & AUTO_REQ_FLAG_DRAW_RASTER) {
  184.            if (width1 > width2) {
  185.           inner_width += 2 * AUTO_REQ_HORIZ_OFFSET;
  186.            } else {
  187.           if ((width1 + 2 * AUTO_REQ_HORIZ_OFFSET) > width2) {
  188.              inner_width += (width1 + 2 * AUTO_REQ_HORIZ_OFFSET) -
  189.                                      width2;
  190.           }
  191.            }
  192.            inner_height += 2 * AUTO_REQ_VERT_OFFSET;
  193.         }
  194.  
  195.         /* Calc width and height of requester window */
  196.         width  = inner_width + 2 * AUTO_REQ_HORIZ_OFFSET;
  197.         height = inner_height + AUTO_REQ_GADGET_VERT_SPACING +
  198.                       gad_height + AUTO_REQ_VERT_OFFSET;
  199.         /* Init gadget data and create gadget list */
  200.         flags = (req_flags & AUTO_REQ_FLAG_HOTKEY ?
  201.                            GADGET_DATA_FLAG_HOTKEY : 0);
  202.         if (pos_text) {
  203.            gd->gd_Type     = GADGET_DATA_TYPE_BUTTON;
  204.            gd->gd_Flags    = flags |
  205.                    (req_flags & AUTO_REQ_FLAG_MOVE_POINTER_POS ?
  206.                      GADGET_DATA_FLAG_MOVE_POINTER : 0);
  207.            gd->gd_LeftEdge = (num_gadgets == 2 ? AUTO_REQ_HORIZ_OFFSET :
  208.                            (width - gad_width) / 2);
  209.            gd->gd_TopEdge  = height - (gad_height + AUTO_REQ_VERT_OFFSET);
  210.            gd->gd_Width    = gad_width;
  211.            gd->gd_Height   = gad_height;
  212.            gd->gd_Text     = pos_text;
  213.            gd->gd_TextAttr = ta;
  214.            gd++;
  215.         }
  216.         if (neg_text) {
  217.            gd->gd_Type     = GADGET_DATA_TYPE_BUTTON;
  218.            gd->gd_Flags    = flags |
  219.                    (req_flags & AUTO_REQ_FLAG_MOVE_POINTER_NEG ?
  220.                      GADGET_DATA_FLAG_MOVE_POINTER : 0);
  221.            gd->gd_LeftEdge = (num_gadgets == 2 ? width - (gad_width +
  222.               AUTO_REQ_HORIZ_OFFSET) : (width - gad_width) / 2);
  223.            gd->gd_TopEdge  = height - (gad_height + AUTO_REQ_VERT_OFFSET);
  224.            gd->gd_Width    = gad_width;
  225.            gd->gd_Height   = gad_height;
  226.            gd->gd_Text     = neg_text;
  227.            gd->gd_TextAttr = ta;
  228.            gd++;
  229.         }
  230.         gd->gd_Type = INTUISUP_DATA_END;
  231.         if (gl = create_gadgets(ri, &gadget_data[0], 0, 0,
  232.                              language_text_array)) {
  233.            struct NewWindow  new_win, *nw = &new_win;
  234.            struct Window     *win;
  235.            SHORT left_edge = 0, top_edge = 0;
  236.  
  237.            /* Calc position of requester window */
  238.            if (req_flags & AUTO_REQ_FLAG_CENTER_MOUSE) {
  239.           struct Gadget  *gad = gadget_address(gl, num_gadgets - 1);
  240.  
  241.           /* Center last gadget of requester window over current position of mouse pointer */
  242.           left_edge = ri->ri_Screen->MouseX -
  243.                         (gad->LeftEdge + gad->Width / 2);
  244.           top_edge  = ri->ri_Screen->MouseY -
  245.                         (gad->TopEdge + gad->Height / 2);
  246.           if (ri->ri_Flags & RENDER_INFO_FLAG_INNER_WINDOW) {
  247.              left_edge += ri->ri_WindowBorderLeft;
  248.              top_edge  += ri->ri_WindowBorderTop;
  249.           }
  250.  
  251.           /* Scale window position according to screen dimension */
  252.           if (left_edge < 0) {
  253.              left_edge = 0;
  254.           } else {
  255.              USHORT max_width = ri->ri_ScreenWidth;
  256.  
  257.              if (left_edge > (max_width - width)) {
  258.             left_edge = max_width - width;
  259.              }
  260.           }
  261.           if (top_edge < 0) {
  262.              top_edge = 0;
  263.           } else {
  264.              USHORT max_height = ri->ri_ScreenHeight;
  265.  
  266.              if (top_edge > (max_height - height)) {
  267.             top_edge = max_height - height;
  268.              }
  269.           }
  270.            }
  271.  
  272.            /* Init and open requester window */
  273.            nw->LeftEdge    = left_edge;
  274.            nw->TopEdge     = top_edge;
  275.            nw->Width       = width;
  276.            nw->Height      = height;
  277.            nw->DetailPen   = AUTO_REQ_DETAIL_PEN;
  278.            nw->BlockPen    = AUTO_REQ_BLOCK_PEN;
  279.            nw->IDCMPFlags  = AUTO_REQ_IDCMP_FLAGS;
  280.            nw->Flags       = AUTO_REQ_FLAGS;
  281.            nw->FirstGadget = NULL;
  282.            nw->CheckMark   = NULL;
  283.            nw->Title       = (UBYTE *)(title ? get_language_text(title,
  284.                  language_text_array) :    " System Request ");
  285.            nw->Screen      = screen;
  286.            nw->BitMap      = NULL;
  287.            nw->MinWidth    = 0;
  288.            nw->MinHeight   = 0;
  289.            nw->MaxWidth    = 0;
  290.            nw->MaxHeight   = 0;
  291.            nw->Type        = (screen ? screen->Flags & SCREENTYPE :
  292.                                   WBENCHSCREEN);
  293.            flags = (req_flags & AUTO_REQ_FLAG_RENDER_PENS ?
  294.                       OPEN_WINDOW_FLAG_RENDER_PENS : 0);
  295.            if (win = open_window(ri, nw, (USHORT)flags)) {
  296.           struct MsgPort  *up = win->UserPort;
  297.           struct Screen   *front_screen;
  298.           SHORT mouse_x, mouse_y;
  299.           LONG  ilock;
  300.           BOOL  keepon = TRUE;
  301.  
  302.           /* Save current mouse pointer position */
  303.           if (req_flags & AUTO_REQ_FLAG_MOVE_POINTER_POS ||
  304.                    req_flags & AUTO_REQ_FLAG_MOVE_POINTER_NEG) {
  305.              mouse_x = win->MouseX;
  306.              mouse_y = win->MouseY;
  307.           }
  308.  
  309.           /* Draw raster and border around text area */
  310.           if (req_flags & AUTO_REQ_FLAG_DRAW_RASTER) {
  311.              clear_window(ri, win, 0, 0, width, height,
  312.                           CLEAR_WINDOW_FLAG_USE_RASTER);
  313.              clear_window(ri, win, AUTO_REQ_HORIZ_OFFSET,
  314.             AUTO_REQ_VERT_OFFSET, inner_width, inner_height, 0);
  315.              draw_border(ri, win, AUTO_REQ_HORIZ_OFFSET,
  316.                 AUTO_REQ_VERT_OFFSET, inner_width, inner_height,
  317.                           BORDER_DATA_TYPE_BOX1_IN);
  318.              /* Calc start position of text lines */
  319.              left_edge = 2 * AUTO_REQ_HORIZ_OFFSET;
  320.              top_edge  = 2 * AUTO_REQ_VERT_OFFSET;
  321.           } else {
  322.  
  323.              /* Calc start position of text lines */
  324.              left_edge = AUTO_REQ_HORIZ_OFFSET;
  325.              top_edge  = AUTO_REQ_VERT_OFFSET;
  326.           }
  327.  
  328.           /* Display texts and gadgets */
  329.           line  = text;
  330.           flags = (req_flags & AUTO_REQ_FLAG_TEXT_CENTER ?
  331.                         TEXT_DATA_FLAG_CENTER : 0) |
  332.                     (req_flags & AUTO_REQ_FLAG_TEXT_COLOR2 ?
  333.                          TEXT_DATA_FLAG_COLOR2 : 0);
  334.           while (count--) {
  335.              print_text(ri, win, line + 1, left_edge, top_edge,
  336.                     TEXT_DATA_TYPE_TEXT, (USHORT)flags, ta);
  337.              line     += *line + 2;
  338.              top_edge += ta->ta_YSize + AUTO_REQ_VERT_SPACING;
  339.           }
  340.           display_gadgets(win, gl);
  341.  
  342.           /* Save current font scren and bring our screen to front */
  343.           ilock = LockIBase((LONG)NULL);
  344.           front_screen = IntuitionBase->FirstScreen;
  345.           UnlockIBase(ilock);
  346.           ScreenToFront(win->WScreen);
  347.  
  348.           /* Beep if necessary */
  349.           if (req_flags & AUTO_REQ_FLAG_BEEP) {
  350.              DisplayBeep(NULL);
  351.           }
  352.  
  353.           /* Wait for gadget or other IDCMP action */
  354.           do {
  355.              struct IntuiMessage  *msg;
  356.  
  357.              WaitPort(up);
  358.              while (msg = get_msg(up)) {
  359.             ULONG class = msg->Class;
  360.  
  361.             if (class == ISUP_ID) {
  362.                if (pos_text && msg->Code == 0) {
  363.                   result = TRUE;
  364.                }
  365.                keepon = FALSE;
  366.             } else {
  367.                if (pos_text && (class & pos_idcmp_flags)) {
  368.                   result = TRUE;
  369.                   keepon = FALSE;
  370.                } else {
  371.                   if (neg_text && (class & neg_idcmp_flags)) {
  372.                  keepon = FALSE;
  373.                   }
  374.                }
  375.             }
  376.             reply_msg(msg);
  377.              }
  378.           } while (keepon == TRUE);
  379.           remove_gadgets(gl);
  380.  
  381.           /* Before closing window restore old mouse pointer position */
  382.           if (req_flags & AUTO_REQ_FLAG_MOVE_POINTER_POS ||
  383.                    req_flags & AUTO_REQ_FLAG_MOVE_POINTER_NEG) {
  384.              move_mouse_pointer(win, mouse_x, mouse_y, FALSE);
  385.           }
  386.           close_window(win, FALSE);
  387.  
  388.           /* Bring old screen back to front */
  389.           ilock = LockIBase((LONG)NULL);
  390.           if (IntuitionBase->FirstScreen == front_screen) {
  391.              front_screen = NULL;
  392.           }
  393.           UnlockIBase(ilock);
  394.           if (front_screen) {
  395.              ScreenToFront(front_screen);
  396.           }
  397.            }
  398.            free_gadgets(gl);
  399.         }
  400.         FreeMem(text, text_len);
  401.      }
  402.      free_render_info(ri);
  403.       }
  404.       if (req_win) {
  405.  
  406.      /* Enable gadgets and menu for given window */
  407.      restore_mouse_pointer(req_win);
  408.       }
  409.    }
  410.    return(result);
  411. }
  412.     /* Display requester on given window */
  413.  
  414.    struct RequesterList *
  415. display_requester(struct Window  *req_win, struct RequesterData  *rd,
  416.                          BYTE **language_text_array)
  417. {
  418.    if (req_win && rd && rd->rd_Gadgets) {
  419.       struct RequesterList  *rl;
  420.       USHORT rd_flags = rd->rd_Flags;
  421.  
  422.       /* Alloc requester list and remove visible gadget list from window */
  423.       if (rl = AllocMem((LONG)sizeof(struct RequesterList),
  424.                       (LONG)MEMF_PUBLIC | MEMF_CLEAR)) {
  425.      struct Screen      *screen;
  426.      struct RenderInfo  *ri;
  427.      USHORT flags;
  428.  
  429.      /* Remove gadgets and menu from given window */
  430.      change_mouse_pointer(req_win, NULL, TRUE);
  431.  
  432.      /* Get render info */
  433.      screen = req_win->WScreen;
  434.      flags  = (rd_flags & REQ_DATA_FLAG_INNER_WINDOW ?
  435.                     RENDER_INFO_FLAG_INNER_WINDOW : 0) |
  436.           (rd_flags & REQ_DATA_FLAG_BACK_FILL ?
  437.                        RENDER_INFO_FLAG_BACK_FILL : 0) |
  438.           (rd_flags & REQ_DATA_FLAG_AVAIL_FONTS ?
  439.                       RENDER_INFO_FLAG_AVAIL_FONTS : 0);
  440.      if (ri = get_render_info(screen, flags)) {
  441.         struct GadgetData  *gd = rd->rd_Gadgets;
  442.         struct GadgetList  *gl;
  443.  
  444.         /* Init gadgets */
  445.         if (gl = create_gadgets(ri, gd, 0, 0, language_text_array)) {
  446.            struct NewWindow  new_win, *nw = &new_win;
  447.            struct Window     *win;
  448.            SHORT left_edge = 0, top_edge = 0;
  449.  
  450.            /* Calc position of requester window */
  451.            if ((rd_flags & REQ_DATA_FLAG_CENTER_WINDOW) ||
  452.                   (rd_flags & REQ_DATA_FLAG_CENTER_MOUSE)) {
  453.           USHORT width = rd->rd_Width, height = rd->rd_Height;
  454.  
  455.           if (rd_flags & REQ_DATA_FLAG_CENTER_WINDOW) {
  456.  
  457.              /* Center requester window on given window */
  458.              left_edge = req_win->LeftEdge +
  459.                            (req_win->Width - width) / 2;
  460.              top_edge  = req_win->TopEdge +
  461.                          (req_win->Height - height) / 2;
  462.           } else {
  463.  
  464.              /* Center last gadget of requester window over current position of mouse pointer */
  465.              left_edge = ri->ri_Screen->MouseX - width / 2;
  466.              top_edge  = ri->ri_Screen->MouseY - height / 2;
  467.           }
  468.           if (ri->ri_Flags & RENDER_INFO_FLAG_INNER_WINDOW) {
  469.              left_edge += ri->ri_WindowBorderLeft;
  470.              top_edge  += ri->ri_WindowBorderTop;
  471.           }
  472.  
  473.           /* Scale window position according to screen dimension */
  474.           if (left_edge < 0) {
  475.              left_edge = 0;
  476.           } else {
  477.              USHORT max_width = ri->ri_ScreenWidth;
  478.  
  479.              if (left_edge > (max_width - width)) {
  480.             left_edge = max_width - width;
  481.              }
  482.           }
  483.           if (top_edge < 0) {
  484.              top_edge = 0;
  485.           } else {
  486.              USHORT max_height = ri->ri_ScreenHeight;
  487.  
  488.              if (top_edge > (max_height - height)) {
  489.             top_edge = max_height - height;
  490.              }
  491.           }
  492.            }
  493.  
  494.            /* Save requester list ptr */
  495.            gl->gl_RequesterList = rl;
  496.  
  497.            /* Init and open requester window */
  498.            nw->LeftEdge    = left_edge;
  499.            nw->TopEdge     = top_edge;
  500.            nw->Width       = rd->rd_Width;
  501.            nw->Height      = rd->rd_Height;
  502.            nw->DetailPen   = REQ_DETAIL_PEN;
  503.            nw->BlockPen    = REQ_BLOCK_PEN;
  504.            nw->IDCMPFlags  = NULL;   /* shared user port !!! */
  505.            nw->Flags       = REQ_FLAGS |
  506.            (rd_flags & REQ_DATA_FLAG_DRAG_GADGET ? WINDOWDRAG : 0) |
  507.           (rd_flags & REQ_DATA_FLAG_DEPTH_GADGET ? WINDOWDEPTH : 0);
  508.            nw->FirstGadget = NULL;
  509.            nw->CheckMark   = NULL;
  510.            nw->Title       = (UBYTE *)(rd->rd_Title ?
  511.               get_language_text(rd->rd_Title, language_text_array) :
  512.                                  " Requester ");
  513.            nw->Screen      = screen;
  514.            nw->BitMap      = NULL;
  515.            nw->MinWidth    = 0;
  516.            nw->MinHeight   = 0;
  517.            nw->MaxWidth    = 0;
  518.            nw->MaxHeight   = 0;
  519.            nw->Type        = (screen ? screen->Flags & SCREENTYPE :
  520.                                   WBENCHSCREEN);
  521.            flags = (rd_flags & REQ_DATA_FLAG_RENDER_PENS ?
  522.                      OPEN_WINDOW_FLAG_RENDER_PENS : 0) |
  523.                (rd_flags & REQ_DATA_FLAG_CENTER_SCREEN ?
  524.                     OPEN_WINDOW_FLAG_CENTER_SCREEN : 0);
  525.            if (win = open_window(ri, nw, flags)) {
  526.           struct BorderData  *bd = rd->rd_Borders;
  527.  
  528.           /* Enable shared user port */
  529.           win->UserPort = req_win->UserPort;
  530.           ModifyIDCMP(win, REQ_IDCMP_FLAGS);
  531.  
  532.           /* Init requester list */
  533.           rl->rl_ID         = ISUP_ID;
  534.           rl->rl_Flags      = 0;
  535.           rl->rl_RenderInfo = ri;
  536.           rl->rl_Window     = req_win;
  537.           rl->rl_ReqWindow  = win;
  538.           rl->rl_GadgetList = gl;
  539.  
  540.           /* Save current mouse pointer position if necessay */
  541.           for ( ; gd->gd_Type != INTUISUP_DATA_END; gd++) {
  542.              if (gd->gd_Flags & GADGET_DATA_FLAG_MOVE_POINTER) {
  543.             rl->rl_Flags |= REQ_FLAG_RESTORE_POINTER_POS;
  544.             rl->rl_MouseX = win->MouseX;
  545.             rl->rl_MouseY = win->MouseY;
  546.             break;
  547.              }
  548.           }
  549.  
  550.           /* Draw raster from first border */
  551.           if ((rd_flags & REQ_DATA_FLAG_DRAW_RASTER) &&
  552.                            bd && bd->bd_Type >= 1 &&
  553.                       bd->bd_Type <= MAX_BORDER_DATA_TYPE) {
  554.              SHORT left_edge = bd->bd_LeftEdge,
  555.                top_edge = bd->bd_TopEdge, width = bd->bd_Width,
  556.                height = bd->bd_Height;
  557.  
  558.              /* Draw raster and border */
  559.              clear_window(ri, win, 0, 0, rd->rd_Width,
  560.                    rd->rd_Height, CLEAR_WINDOW_FLAG_USE_RASTER);
  561.              clear_window(ri, win, left_edge, top_edge, width,
  562.                                  height, 0);
  563.              draw_border(ri, win, left_edge, top_edge, width,
  564.                       height, BORDER_DATA_TYPE_BOX1_IN);
  565.              /* Don't draw this border later */
  566.              bd++;
  567.           }
  568.  
  569.           /* Display texts, borders and gadgets */
  570.           display_texts(ri, win, rd->rd_Texts, 0, 0,
  571.                                language_text_array);
  572.           display_borders(ri, win, bd, 0, 0);
  573.           display_gadgets(win, gl);
  574.           return(rl);
  575.            }
  576.            free_gadgets(gl);
  577.         }
  578.         free_render_info(ri);
  579.      }
  580.  
  581.      /* Enable gadgets and menu for given window */
  582.      restore_mouse_pointer(rl->rl_Window);
  583.      FreeMem(rl, (LONG)sizeof(struct RequesterList));
  584.       }
  585.    }
  586.    return(NULL);
  587. }
  588.     /* Remove given requester */
  589.  
  590.    VOID
  591. remove_requester(struct RequesterList  *rl)
  592. {
  593.    if (rl && rl->rl_ID == ISUP_ID) {
  594.       remove_gadgets(rl->rl_GadgetList);
  595.  
  596.       /* Before closing window restore old mouse pointer position */
  597.       if (rl->rl_Flags & REQ_FLAG_RESTORE_POINTER_POS) {
  598.      move_mouse_pointer(rl->rl_ReqWindow, rl->rl_MouseX, rl->rl_MouseY,
  599.                                      FALSE);
  600.       }
  601.       close_window(rl->rl_ReqWindow, TRUE);   /* shared user port !!! */
  602.  
  603.       /* Free resources */
  604.       free_gadgets(rl->rl_GadgetList);
  605.       free_render_info(rl->rl_RenderInfo);
  606.  
  607.       /* Enable gadgets and menu for given window */
  608.       restore_mouse_pointer(rl->rl_Window);
  609.       FreeMem(rl, (LONG)sizeof(struct RequesterList));
  610.    }
  611. }
  612.